#include<stdio.h>
#include <sys/time.h>
#include<signal.h>

void myfunc(int sig)
{
    printf("hello\n");
}
//int setitimer(int which,  const struct itimerval *new_value, struct itimerval *old_value);
int main()
{
    struct itimerval new_value;

    //定时周期
    new_value.it_interval.tv_sec = 1;
    new_value.it_interval.tv_usec = 0;

    //第一次触发的时间
    new_value.it_value.tv_sec = 2;
    new_value.it_value.tv_usec = 0;

    signal(SIGALRM, myfunc); //信号处理
    setitimer(ITIMER_REAL, &new_value, NULL); //定时器设置
  
    while (1);

    return 0;
}